<?php
/**
 * 
 * Enter description : thực thi kich hoat tài khoản email 
 * @author admin888
 *
 */
class  Model_Kickhoat extends Zend_Db_Table
{
	protected $_thanhvien = "thanhvien"; 
	protected $_cauhinh = "cau_hinh_user";
	
	public function __construct()
	{
	  $this->_db =  Zend_Registry::get('connectDb');
	}
	/**
	 * admin888 <doan.hut@gmail.com>
	 * Enter description :kich hoat thành viên 
	 * @param unknown_type $idtv
	 */
	public function khichhoathanhvien($idtv)
	{
		$date =  date('d-m-Y H:i:s');
		$arr = array(
				'kichhoat'    =>1,
				'nguoi_sua'   =>$idtv,
				'ngay_sua'	  =>$date	
		);
		$where = "uid = ".$idtv;
		$query = $this->_db->update($this->_thanhvien, $arr,$where);
	 return  $query;
	}
	/**
	 * admin888 <doan.hut@gmail.com>
	 * Enter description : thuc thu thi add i ban ghi cho bang cau_hinh_user 
	 * @param unknown_type $dulieu
	 */
	public function kichhoatcauhinh($idtv)
	{
		$date =  date('d-m-Y H:i:s');
		//add ban ghi vao bang cai hinh
		$arr = array(
			'uid' => $idtv,
			'loai_mahoa' => 'ssl',
			'ngay-tao' => $date,
			'ngay_sua' => $date,
			'nguoi_sua' => $idtv,
			'nguoi_tao' => $idtv
		
		);
		$add = $this->_db->insert($this->_cauhinh, $arr);
		return $add;
		
	}
	/**
	 * admin888 <doan.hut@gmail.com>
	 * Enter description : get tai khoan eamil
	 * @param unknown_type $data
	 */
	public function getemailkh($data)
	{
		$sql = $this->_db->select()
						 ->from($this->_thanhvien)
						 ->where($this->_thanhvien.'.uname = "'.$data['tentaikhoan'].'"');
						 //echo $sql ; die();
		$query = $this->_db->fetchRow($sql);				  
	return  $query;	
	}
	/**
	 * admin888 <doan.hut@gmail.com>
	 * Enter description : updatepass thành vien
	 * @param unknown_type $data
	 */
	public function getchangepass($data)
	{
		$date =  date('d-m-Y H:i:s');
		$array = array(
			'pass'   		=>md5(trim($data['mk'])),
			'ngay_sua'		=>$date,
			'nguoi_sua'		=>$data['uid']
		);
		$where = "uid =".$data['uid'];
		$query =  $this->_db->update($this->_thanhvien, $array,$where);
	return $query;	
		
	}	

}